<template>
  <div class="tableWrapper">
    <div class="title">中压线路汇总</div>
    <div class="xlhz">
        <el-form :model="xlhzForm" ref="xlhzForm" label-width="160px">
            <el-row>
                <el-col :span="8">
                    <el-form-item label="电缆长度(km)">
                        <el-input v-model="xlhzForm.dlcd" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="架空裸导线(km)">
                        <el-input v-model="xlhzForm.ldxcd" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="架空绝缘线(km)">
                        <el-input v-model="xlhzForm.jyxcd" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="线路合计(km)">
                        <el-input v-model="xlhzForm.xlhj" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="断路器台数">
                        <el-input v-model="xlhzForm.dlqts" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="开关设备台数">
                        <el-input v-model="xlhzForm.kgts" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="电容器台数">
                        <el-input v-model="xlhzForm.drqts" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="专用用户数">
                        <el-input v-model="xlhzForm.zyyhs" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="专用变台数">
                        <el-input v-model="xlhzForm.zybts" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="专用变容量(kVA)">
                        <el-input v-model="xlhzForm.zybrl" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="专用设备台数">
                        <el-input v-model="xlhzForm.zysbts" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="专用设备容量(kVA)">
                        <el-input v-model="xlhzForm.zysbrl" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="专用户总容量(kVA)">
                        <el-input v-model="xlhzForm.zyyhrl" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="公用用户数">
                        <el-input v-model="xlhzForm.gyyhs" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="公用变台数">
                        <el-input v-model="xlhzForm.gybts" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="公用变总容量(kVA)">
                        <el-input v-model="xlhzForm.gybrl" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="双电源容量(kVA)">
                        <el-input v-model="xlhzForm.sdyrl" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="双电源户数">
                        <el-input v-model="xlhzForm.sdyhs" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="变压器总台数">
                        <el-input v-model="xlhzForm.byqts" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="变压器总容量(kVA)">
                        <el-input v-model="xlhzForm.byqrl" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="总用户数">
                        <el-input v-model="xlhzForm.zyhs" disabled></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="16">
                    <el-form-item label="开闭所室数">
                        <el-input v-model="xlhzForm.kzss" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="用户总容量(kVA)">
                        <el-input v-model="xlhzForm.yhzrl" disabled></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
    </div>
  </div>
</template>

<script>
import { sumZczyXl } from '@/api/sjwh/zczy.js';
export default {
  data() {
    return {
        xlhzForm: {}
        // xlhzForm: {
        //     dlcd: '', // 电缆长度
        //     ldxcd: '', // 架空裸导线长度
        //     jyxcd: '', // 架空绝缘线长度
        //     xlhj: '', // 线路合计
        //     dlqts: '', // 断路器台数
        //     kgts: '', // 开关设备台数
        //     drqts: '', // 电容器台数
        //     zyyhs: '', // 专用用户数
        //     zybts: '', // 专用变台数
        //     zybrl: '', // 专用变容量
        //     zysbts: '', // 专用设备台数
        //     zysbrl: '', //专用设备容量
        //     zyyhrl: '', // 专用用户总容量
        //     gyyhs: '', // 公用用户数
        //     gybts: '', // 公用变台数
        //     gybrl: '', // 公用变总容量
        //     sdyrl: '', // 双电源容量
        //     sdyhs: '', // 双电源户数
        //     byqrl: '', // 变压器总容量
        //     byqts: '', // 变压器总台数
        //     zyhs: '' // 总用户数
        // }
    }
  },
  props: {
    propData: {
      type: Object,
      default: function() {
        return {};
      }
    }
  },
  watch: {
    propData: {
      deep: true,
      immediate: true,
      handler(newVal, oldVal) {
        const that = this
        if (newVal.isly) {
            that.getXlhz(newVal.dwbm, newVal.xdbm, '1')
        } else {
            that.getXlhz(newVal.dwbm, newVal.xdbm)  
        }
      }
    }
  },
  methods: {
    async getXlhz(dwbm, xdbm, cxkg) {
        const that = this
        let xlhzObj = null
        if (cxkg) {
            xlhzObj = {
                cxkg,
                dwbm,
                xdbm
            }
        } else {
            xlhzObj = {
                dwbm,
                xdbm
            }
        }
        let res =  await sumZczyXl(xlhzObj)
        if (res.code == 0) {
            that.xlhzForm = res.data
        } else {
            that.$message.warning(res.message)
        }
    }
  }
}
</script>

<style lang="scss" scoped>
.title {
  font-size: 18px;
  height: 20px;
  line-height: 20px;
  margin-bottom: 8px;
}
</style>
